<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>定位和居中元素</title>
    <style type="text/css">
        *{
            margin: 0px;
            top:0px;
        }
        .wrap{
            width: 400px;
            height: 200px;
            left:50%;
            position: absolute;
            top:50%;
            background-color: #eeeeee;
            margin-top: -100px;
            margin-left: -200px;
            overflow: hidden;
        }
        .left{
            background-color: darkorange;
            width: 100px;
            height: 100px;
            border-radius: 50px;
            position: absolute;
            top:-50px;
            left: -50px;
        }
        .right{
            background-color: darkorange;
            width: 100px;
            height: 100px;
            border-radius: 50px;
            position: absolute;
            top:150px;
            right: -50px;
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="left"></div>
        <div class="right"></div>
    </div>
</body>
</html>